/**
 * 
 * purpose: STORE LOG INFO...
 * @auth: Ning
 * date: 2009-9-26
 * 
 * */
package core.section.session
{
	import core.section.SectionController;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class SessionManager extends EventDispatcher
	{
		//START...
		
		private static var regSections:Object = new Object;
		
		public static var userInfo:Object;
		
		//register...
		public static function register(section:SectionController):void
		{
			
			regSections[section.pagename] = section;		
			
												
		}
		
		
		//unregister...
		public static function unregister(section:SectionController):void
		{
			
			if(regSections.hasOwnProperty(section.pagename))
			{
				
				delete regSections[section.pagename];
				
			}
			
		}
		
				
		//login...
		public static function login(info:Object):void
		{
			
			userInfo = info;
			
			for(var prop:String in regSections)
			{
				
				(regSections[prop] as SectionController).onLogin(userInfo);
				
			}
			
			
		}
		
		//log out...
		public static function logout():void
		{
			
			userInfo = null;
			
			for(var prop:String in regSections)
			{
				
				(regSections[prop] as SectionController).onLogout();
				
			}
			
		}	
		
		
		
		//END...
	}
}